<!DOCTYPE HTML>
<html lang="en">
<head>
    <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
    <link rel="icon" type="image/x-icon" href="img/head/favicon.ico" />
    <link rel="stylesheet" href="css/login.css"/>
    <meta name="keywords" content="网上商城, 电商平台, 能源互联网">
    <meta name="description" content="能源互联网, 网上商城, 电商平台, 电子商务, 掌上e宝, 科技金服, 不正经网站研究中心">
    <title>欢迎登录网上商城</title>
    <noscript>抱歉，你的浏览器不支持 JavaScript!</noscript>
    <script type="text/javascript" src="js/common/jquery-1.11.3.min.js"></script>
    <!--   <script type="text/javascript" src="js/cookie.js"></script>-->
</head>
<body>
<img src="./img/head/logo.png" alt="logo" style="position: absolute;top: 8%;left: 12%;">
<h1>欢迎登陆网上商城</h1>
<form id="loginForm" >
    <table>
        <tr>
            <td colspan="2" style="color: red;text-align: center;" class="tdx" id="alert"></td>
        </tr>
        <tr>
            <td class="tdx"><label >手&nbsp;机&nbsp;号：</label></td>
            <td>
                <input name="phone" id="phone" type="text" class="form-control" onchange="dian()"/>
                <span style="color:red"></span>
            </td>
        </tr>

        <tr>
            <td class="tdx"><label >验&nbsp;证&nbsp;码：</label></td>
            <td>
                <input name="code"  id="code" type="text" class="form-control"/>
                <button type="button" onclick="postCode()" class="btn btn-success glyphicon glyphicon-search">发送验证码</button>


                <span style="color:#ff0000"></span>
            </td>
        </tr>
        <!--      <tr>
                  <td colspan="2" style="text-align: center;">

                  </td>
              </tr>-->
        <tr>
            <td colspan="2" style="text-align: center;">
                <center><button type="button" onclick="login()" class="btn btn-info" >登录</button></center>
            </td>
        </tr>
    </table>
</form>
<!---->

</body>
<script type="text/javascript">
    function login(){
        $.ajax({
            url:'doLogin',
            type:'post',
            data:$("#loginForm").serialize(),
            dataType:'json',
            success:function(data){
                alert(data.message)
                if(data.code==200){
                     sessionStorage.setItem("name",$("#phone").val());
                    location.href = "index.html";
                }else{
                    sessionStorage.setItem("name",$("#phone").val());
                    location.href = "index.html";
                }
            }
        })
    }
    function postCode(){
        var phone=$("#phone").val()
        $.ajax({
            url:"postCode",
            type:"post",
            data:{phone:phone},
            success:function(data){
                alert(data.message)
                /*if (data.code==200) {
                    bootbox.alert({
                        message: data.msg,
                        size: 'small'
                    })
                }else{
                    bootbox.alert({
                        message: data.msg,
                        size: 'small'
                    })
                }*/
            }
        })
    }

</script>
</html>